import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import './plugins/element.js'
import './assets/css/global.css'

// 设置axios的全局配置
import axios from 'axios'
import qs from 'qs'

// axios拦截器,相当于一个请求预处理,对需要token值的请求处理
axios.interceptors.request.use(function (config) {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
// axios.interceptors.request.use(function (config) {
//   config.headers.ContentType = 'application/x-www-form-urlencoded; charset=utf-8'
// }, function (err) {
//   console.log(err);
// })

//设置请求头，并且挂载qs和axios到Vue的原型对象上
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'
Vue.prototype.$qs = qs
Vue.prototype.$http = axios

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
